﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WOWORTaskAdd.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.WModel.WOWORTaskAdd" %>
<form id="WOWORTaskAddform1" method="post" action="WModel/WOWORTaskAdd.aspx?ajaxmethod=search" onsubmit="return navTabSearch(this);">
<div class="pageHeader">
    <div class="searchBar">
        <table class="searchContent">
           
            <tr>
                <td>请选择需要生产的作业：</td>
                <td>
                    <select name="PID" onchange="$('#WOWORTaskAddform1').submit()">
                        <%=GetProject() %>
                    </select>
                </td>
                <td style="color:Red; font-weight:bold;">
                    <%=Sended?"此项目已下发过生产任务,无法再发布":""%>
                </td>         
               
            </tr>
             <tr>
               
                 <td colspan="3">
                   <b style="">提示：</b>每个作业项目只能制定一个生产任务.
                </td>
            </tr>
        </table>
    </div>
</div>
</form>
<form id="form2" runat="server" method="post" action="WModel/WOWORTaskAdd.aspx?ajaxmethod=addtask" onsubmit="return validateCallbackWOWORTaskAdd(this, navTabAjaxDone);">
<div class="pageContent">
<input type="hidden" name="PID" value="<%=PID %>" />
<input type="hidden" name="MacNum" value="<%=pObj.MacNum %>" />
    <table class="list" width="900" layouth="100">
        <thead>
            <tr  >                
               
                <th width="100">
                    项目名称
                </th>
                 <th width="70">
                    生产订单号
                </th>
                <th width="110">
                    机号范围
                </th>
                <th width="60">
                    计划台数
                </th>                               
                <th width="60">
                    收货台数
                </th>
                <th width="90">
                    已下发料台数
                </th> 
                <th width="100">本次需发料台数</th>
                <th width="120">SAP生产下单日期</th>
                <th width="80">计划生产日期</th>
            </tr>
        </thead>
        <tbody>
    <asp:repeater id="rpMenu" runat="server">
        <HeaderTemplate>
        
        </HeaderTemplate>
        <ItemTemplate>
            <tr >
				<td><%# Eval("PName")%></td>
				<td>
                    <%# Eval("docnum")%>
                     <input type="hidden" name="docnum" value="<%# Eval("docnum")%>" />
                </td>
				<td><%# Eval("u_jh")%></td>
                <td><%# Convert.ToDecimal(Eval("PlannedQty")).ToString("F2")%></td>
                <td><%# Convert.ToDecimal(Eval("CmpltQty")).ToString("F2")%></td>
                <td><%# Convert.ToDecimal(Eval("AllSendQty") == DBNull.Value ? 0 : Eval("AllSendQty")).ToString("F2")%></td>
                <td>
                    <input type="text" style="width:70px;" name="SendQty" class="inputFloat WOWORTaskAddSendQty" value="0" <%=Sended?"readonly":"" %> maxvalue=<%#Convert.ToDecimal(Eval("PlannedQty"))-Convert.ToDecimal(Eval("AllSendQty") == DBNull.Value ? 0 : Eval("AllSendQty")) %> />
                </td>
                <td><%# Eval("PostDate")%></td>
                <td><%# Eval("DueDate")%></td>
			</tr>
        </ItemTemplate>
        <FooterTemplate>
            
        </FooterTemplate>
    </asp:repeater>
    </tbody>
         </table>
   <div class="formBar">
        <ul>
            <%if(!Sended) {%>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            保存</button></div>
                </div>
            </li>
            <%} %>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
</div>

</form>
 <script type="text/javascript">
     $(document).ready(function () {
        $(".WOWORTaskAddSendQty").change(function () {
      
             var $val =parseFloat( $(this).val());
             var $maxvalue =parseFloat( $(this).attr("maxvalue"));
             if ($val > $maxvalue) {
                 alert("对不起,此生产订单最多只能再下" + $maxvalue + "台");
                 $(this).val($maxvalue);
             }
             else
                 $(this).val($val);
         })
     })


     function validateCallbackWOWORTaskAdd(form, callback) {
         var $form = $(form);
         //var $table = $form.find("tbody.ODailyAdd");
         var errormsg = "";
         var $MacNum = $form.find("input[name='MacNum']").val();
         var $nowSendQty = 0;
         $form.find("input.WOWORTaskAddSendQty").each(function () {
             $nowSendQty += parseFloat( $(this).val());
         })        
         if ($nowSendQty <= 0)
             errormsg = "请输入需要发料的台数";
         else {
             if ($nowSendQty > $MacNum) {
                 errormsg = "输入需要发料的台数总数[" + $nowSendQty + "]不能大于生产作业定义的台数[" + $MacNum + "]";
             }
         }
         if (errormsg != "") {
             alertMsg.confirm(errormsg, {});
             return false;
         }

         //return true;
         return validateCallback(form);
     }
 </script>